#ifndef BRIDGE_H
#define BRIDGE_H
#include <iostream>
#include "javabean.h"
#include <string>

using namespace std;

//引擎
class Engine{
public:
    virtual ~Engine();
    virtual void install()=0;
};
Engine::~Engine(){
}
//引擎

//4000引擎
class Engine4000:public Engine{
    public:
    void install(){
        cout<<"发动机4000安装"<<endl;
    }
};
//4000引擎

//3500 引擎
class Engine3500:public Engine{
    public:
    void install(){
        cout<<"发动机4000安装"<<endl;
    }
};
//3500引擎

//抽象汽车，维护抽象引擎
class Car{
PointerPropertyBuilderByName(Engine,engine,protected)
public:
    Car(Engine* engine);
    virtual ~Car();
    virtual void installEngine()=0;
};
Car::Car(Engine *engine){
    this->m_engine=engine;
}
Car::~Car(){

}
//抽象汽车

//实际汽车，维护抽象引擎，实际引擎由外部引入
class BMW7:public Car{
public:
    BMW7(Engine *e);
public:
    void installEngine();
};

BMW7::BMW7(Engine *e):Car(e){
}

void BMW7::installEngine(){
    cout<<"Bmw7:";
    m_engine->install();
}


int mainbridge()
{
    Engine4000 *eng4 = new Engine4000;
    Engine3500 *eng3 = new Engine3500;
    BMW7 *bm7eg4 = new BMW7(eng4);
    BMW7 *bm7eg3 = new BMW7(eng3);
    bm7eg3->installEngine();
    bm7eg4->installEngine();
    delete bm7eg3;
    delete bm7eg4;
    delete eng3;
    delete eng4;
    return 0;
}


#endif // BRIDGE_H
